﻿using System;
using System.Collections.Generic;
using Terraria.Localization;

namespace Terraria.ModLoader
{
	// Token: 0x020001F7 RID: 503
	public class ModTranslation
	{
		// Token: 0x060015EF RID: 5615 RVA: 0x004148C4 File Offset: 0x00412AC4
		internal ModTranslation(string key, bool defaultEmpty = false)
		{
			if (key.Contains(" "))
			{
				throw new Exception("ModTranslation keys can't contain spaces.");
			}
			this.Key = key;
			this.translations = new Dictionary<int, string>();
			this.translations[1] = (defaultEmpty ? null : key);
		}

		// Token: 0x060015F0 RID: 5616 RVA: 0x00010B09 File Offset: 0x0000ED09
		public void SetDefault(string value)
		{
			this.AddTranslation(1, value);
		}

		// Token: 0x060015F1 RID: 5617 RVA: 0x00010B13 File Offset: 0x0000ED13
		public void AddTranslation(int culture, string value)
		{
			this.translations[culture] = value;
		}

		// Token: 0x060015F2 RID: 5618 RVA: 0x00010B22 File Offset: 0x0000ED22
		public void AddTranslation(string culture, string value)
		{
			this.AddTranslation(GameCulture.FromName(culture).LegacyId, value);
		}

		// Token: 0x060015F3 RID: 5619 RVA: 0x00010B36 File Offset: 0x0000ED36
		public void AddTranslation(GameCulture culture, string value)
		{
			this.AddTranslation(culture.LegacyId, value);
		}

		// Token: 0x060015F4 RID: 5620 RVA: 0x00010B45 File Offset: 0x0000ED45
		public bool IsDefault()
		{
			return this.translations[1] == this.Key;
		}

		// Token: 0x060015F5 RID: 5621 RVA: 0x00010B5E File Offset: 0x0000ED5E
		public string GetDefault()
		{
			return this.GetTranslation(1);
		}

		// Token: 0x060015F6 RID: 5622 RVA: 0x00010B67 File Offset: 0x0000ED67
		public string GetTranslation(int culture)
		{
			if (this.translations.ContainsKey(culture))
			{
				return this.translations[culture];
			}
			return this.translations[1];
		}

		// Token: 0x060015F7 RID: 5623 RVA: 0x00010B90 File Offset: 0x0000ED90
		public string GetTranslation(string culture)
		{
			return this.GetTranslation(GameCulture.FromName(culture).LegacyId);
		}

		// Token: 0x060015F8 RID: 5624 RVA: 0x00010BA3 File Offset: 0x0000EDA3
		public string GetTranslation(GameCulture culture)
		{
			return this.GetTranslation(culture.LegacyId);
		}

		// Token: 0x0400151E RID: 5406
		private const int fallback = 1;

		// Token: 0x0400151F RID: 5407
		public readonly string Key;

		// Token: 0x04001520 RID: 5408
		private Dictionary<int, string> translations;
	}
}
